package threePart.commonlyUsedClass;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class formatDateAndTime {
    public static void main(String[] args) throws ParseException {
        Date date  = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        String currentDateAndTime = sdf.format(date);
        System.out.println("currentDateAndTime: " + currentDateAndTime);

        String day = "2014年02月14日10:35:22";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        try {
            Date date1 = sdf2.parse(day);
            System.out.println("date1: " + date1);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
